import { ContentTypeEnum } from '@/enums/httpEnum';
import { defHttp } from '@/utils/http/axios';
import { ListParams } from './model/AccessKeyModel';

enum Api {
  AccessKey = '/accesskey/',
  List = '/accesskey/list',
}

/**
 * 创建AccessKey
 * @params CreateButtonParams
 * @returns Promise
 */
export const addAccessKey = (service_id?: Number) =>
  defHttp.post(
    {
      url: Api.AccessKey,
      headers: { 'Content-Type': ContentTypeEnum.FORM_DATA },
      params: { service_id },
    },
    { isTransformResponse: false },
  );

/**
 * AccessKey列表
 * @param params ButtonParams
 * @returns
 */
export const getAccessKeyList = (params?: ListParams) =>
  defHttp.get({ url: Api.List, params: params });

/**
 * 禁用AccessKey
 * @param ids
 * @returns
 */
export const changeStatus = (id: Number) =>
  defHttp.post(
    {
      url: `${Api.AccessKey}${id}`,
    },
    { isTransformResponse: false },
  );
